package cn.basic.social.api.qwtalk.channel.internal.request;

import cn.basic.social.api.exception.ApiRuleException;
import cn.basic.social.api.CommonConstants;
import cn.basic.social.api.qwtalk.BaseQwRequest;
import cn.basic.social.api.qwtalk.channel.internal.response.InternalGetAccessTokenResponse;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName InternalGetAccessTokenRequest
 * @Description 获取access_token 文档地址：<a href="https://developer.work.weixin.qq.com/document/path/91039"></a>
 * @Author zlf
 * @Date 2023/8/25 10:59
 */
public class InternalGetAccessTokenRequest extends BaseQwRequest<InternalGetAccessTokenResponse> {

    private final String requestUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
    private String topHttpMethod = CommonConstants.HTTP_METHOD_POST;

    public InternalGetAccessTokenRequest() {
    }

    /**
     * 构造函数用户传了请求地址就用用户的请求地址
     *
     * @param requestUrl 请求地址
     * @author zlf
     * @date 11:09 2023/8/25
     */
    public InternalGetAccessTokenRequest(String requestUrl) {
        if (requestUrl != null && requestUrl != "" && requestUrl.length() > 0) {
            super.setRequestUrl(requestUrl);
        }
        super.setRequestUrl(this.requestUrl);
    }

    @Override
    public String getTopHttpMethod() {
        return this.topHttpMethod;
    }

    @Override
    public void setTopHttpMethod(String topHttpMethod) {
        this.topHttpMethod = topHttpMethod;
    }

    @Override
    public Map<String, String> getTextParams() {
        return new HashMap<>();
    }

    @Override
    public Class<InternalGetAccessTokenResponse> getResponseClass() {
        return InternalGetAccessTokenResponse.class;
    }

    @Override
    public void check() throws ApiRuleException {

    }

    @Override
    public String getTopContentType() {
        return null;
    }

    @Override
    public void setTopContentType(String topContentType) {

    }

    @Override
    public String getRequestUrl() {
        return this.requestUrl;
    }

}
